//
//  ViewController.swift
//  TextFieldDemo
//
//  Created by 李煜 on 2024/6/20.
//

import UIKit
import Then

class ViewController: UIViewController, UITextFieldDelegate {
    lazy var tf0 = UITextField().then {
        $0.text = "1000phone iOS"
        $0.borderStyle = .roundedRect
        $0.delegate = self
        view.addSubview($0)
        $0.frame = .init(x: 20, y: 200, width: 300, height: 40)
    }
    lazy var tf1 = UITextField().then {
        $0.text = "hello swift"
        $0.borderStyle = .roundedRect
        $0.delegate = self
        view.addSubview($0)
        $0.frame = .init(x: 20, y: 300, width: 300, height: 40)
    }
    
    
    override func viewDidLoad() {
        super.viewDidLoad()
        tf0.backgroundColor = .systemBlue
        tf1.backgroundColor = .gray
        
    }
    func textField(_ textField: UITextField, shouldChangeCharactersIn range: NSRange, replacementString string: String) -> Bool {
        debugPrint("location \(range.location)","range.length \(range.length)")
        return true
    }

}

